Document Templates and Rules (DTR) System API - Implementation Template
Setup guide
Importing Templates into Anypoint Studio
- In Studio, click the Exchange X icon in the upper left of the taskbar.
- Log in with your Anypoint Platform credentials.
- Search for the template.
- Click Open.
Running Templates in Anypoint Studio
After you import your template into Studio, follow these configuration steps to run it.
DTR Application Configuration
The application requires a few things to be configured, mainly the system API connection information. Configure them in the properties file located in the config/properties
folder.
mule.env
- sets the environment where the application is to be deployed. It should be configured inconfig-<mule.env>.yaml
file. For a studio deployment, the recommended mule.env value islocal
.mule.key
- sets the encryption password to be used for encrypting secure properties. Update as needed.
Please refer to the attached link on how to secure the configuration properties.
HTTPS Configuration
https.host
— sets the service host interface. It should be configured inconfig-<mule.env>.yaml
file. (Defaults to 0.0.0.0 for all interfaces).https.port
— sets the HTTPS service port number. It should be configured inconfig-<mule.env>.yaml
file. (Default 8082).- TLS Configuration - Keystore properties setup:
keystore.alias
- sets the alias to the keystore. It should be configured inconfig-<mule.env>.yaml
file.keystore.path
- sets the path to the key file. Key should be available in /src/main/resources/keystore. It should be configured inconfig-<mule.env>.yaml
file.keystore.keypass
— sets keystore keypass to support HTTPS operation. It should be encrypted and configured inconfig-secured-<mule.env>.yaml
file.keystore.password
— sets keystore password to support HTTPS operation. It should be encrypted and configured inconfig-secured-<mule.env>.yaml
file.
Please refer to the attached link on how to generate the Keystore.
In Memory Database Configuration
- Rename the database name in /src/main/resources/springbeans.xml bean for "org.apache.commons.dbcp2.BasicDataSource".
- Database script file(create-db.sql) is present in /src/main/resources/dbscripts folder. It has the DB Create commands for schema and table.
- Records to be loaded into the database are in /src/main/resources/dbfiles.
- Java class DerbyInitializer.java has methods defined for creating records, fetching records and truncating table.
- Files are read using file /src/main/resources/dbfiles/templates.md. Column 3 and 4 in the file are inserted into columns resource and respMessage.
Tested and verified
This solution was developed and tested on Anypoint Studio 7.15.0 and Mule Runtime 4.4.0
Running it
- Right-click the template project folder.
- Hover your mouse over 'Run as'.
- Click Mule Application (configure).
- Inside the dialog, select Environment and set the variable mule.env to the appropriate value (e.g., dev or local).
- Inside the dialog, select Environment and set the variable mule.key to the property encryption key that you used to encrypt your secure properties.
- Inside the dialog, go to 'Clear Application Data' select 'always' radio button.
- Click Run.
Deployment instructions for CloudHub using provided scripts
Ensure the Maven profile CloudHub-DEV
has been properly configured in your settings.xml
file. Reference can be found by downloading the Accelerator Common Resources asset. Additional instructions are available in the Getting Started with MuleSoft Accelerators - Build Environment guide.
Update the config-.yaml properties appropriately and then use one of the following scripts to deploy the application to CloudHub:
- packageDeploy.sh or deployOnly.sh (Mac/Linux)
- packageDeploy.cmd or deployOnly.cmd (Windows)
In Memory Database Configuration
Post deployment to CloudHub, please complete the following steps to initialize the in-memory database load.
1. RunTime Manager -> Select the runtime app instance.
2. Select Schedules from the list tabs available for the app.
3. Select the radio button available for the schedule "implementation_run-at-startup_Scheduler" and click on Run Now.
4. This process kicks off the scheduled flow after start up and reloads the files provided in /src/main/resource/dbfiles
as records to the database.
Testing it
- Use Advanced Rest Client or Postman to send a request over HTTPS. The template includes a postman collection in the
src/test/resources
folder. Update the collection variable(s) after successful import.